@ECHO OFF
SET /p SQLSERVER= Give the SQL Server instance name?
SET /p DATABASENAME= Give the DATABASE name?
ECHO.
ECHO ********************************************
ECHO *******LOCAL DATABASE CREATION SCRIPT*******
ECHO ********************************************
ECHO.
ECHO Plese Wait ... [Finding Stored Procedures from all folders.]
@ECHO OFF
DIR ..\..\..\..\SqlServer*.* /S/B > AllStoredProcedureList.txt 
Pause

IF EXIST .\StoredProcedure ERASE .\StoredProcedure\*.* /Q 
IF NOT EXIST .\StoredProcedure MKDIR .\StoredProcedure 
ECHO Plese Wait for couple of seconds ... [Creating local folder.]
Pause

FOR /F %%L IN (AllStoredProcedureList.txt) DO  (COPY %%L .\StoredProcedure /Y > NUL)
ECHO Plese Wait for couple of seconds ... [Copying all sql files.]
Pause

DIR .\StoredProcedure\*.* /S/B > AllStoredProcedureList.txt
rem DIR .\StoredProcedure\*.* /B 2>NUL
DIR .\StoredProcedure\*.* | Find "File(s)" 2>NUL
COPY /Y NUL TempDbAllStoredProcCreationScripts.SQLCMD > NUL
ECHO Plese Wait for couple of seconds ... [Collecting info for dynamic script file.]
pause

ECHO -- ============================================= >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO -- Script Template  >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO -- ============================================= >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO PRINT '** STARTING STORED PROCEDURE CREATION ...' >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO GO >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO :On ERROR EXIT >> TempDbAllStoredProcCreationScripts.SQLCMD
FOR /F %%L in (AllStoredProcedureList.txt) DO ECHO :r %%L >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO Plese Wait for couple of seconds ... [Creating dynamic script file.]
pause

ECHO PRINT '** STORED PROCEDURE CREATED SUCCESSFULLY' >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO GO >> TempDbAllStoredProcCreationScripts.SQLCMD
ECHO Plese Wait for couple of seconds ... [Dynamic script file created...]
PAUSE

ECHO.
SQLCMD -S %SQLSERVER% -E -d %DATABASENAME% -i DbAllTableCreationScriptForLocalDB.SQLCMD
PAUSE

ECHO.
SQLCMD -S %SQLSERVER% -E -d %DATABASENAME% -i TempDbAllStoredProcCreationScripts.SQLCMD
PAUSE

ECHO.
CD .\DefaultDataScripts > NUL
SQLCMD -S %SQLSERVER% -E -d %DATABASENAME% -i DbAllDefaultDataCreationScripts.SQLCMD
PAUSE

ECHO.
CD ..\ > NUL
ECHO Thank you ...
PAUSE
@ECHO ON

